<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
	<head>
	<meta charset="UTF-8">
	<title>管理员信息页面</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="../layui/css/layui.css"/>
	<link rel="stylesheet" type="text/css" href="../css/admin.css"/>

	</head>
	<body>
	<div class="layui-tab page-content-wrap">
		  <ul class="layui-tab-title">
		    <li class="layui-this">查看资料</li>
		    <li>修改密码</li>
		  </ul>
		  <div class="layui-tab-content">
		    <div class="layui-tab-item layui-show">
		    	<form class="layui-form"  style="width: 90%;padding-top: 20px;">
				  <div class="layui-form-item">
				    <label class="layui-form-label">ID：</label>
				    <div class="layui-input-block">
				      <input id="manager_id" type="text" name="id" disabled autocomplete="off" class="layui-input layui-disabled" value="1">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">管理员：</label>
				    <div class="layui-input-block">
				      <input id="manager_name" type="text" name="username" disabled autocomplete="off" class="layui-input layui-disabled" value="admin">
				    </div>
				  </div>

				</form>
		    </div>
		    <div class="layui-tab-item">
		    	<form class="layui-form" v style="width: 90%;padding-top: 20px;">
				  <div class="layui-form-item">
				    <label class="layui-form-label">管理员：</label>
				    <div class="layui-input-block">
				      <input id="manager_name_2" type="text" name="username" disabled autocomplete="off" class="layui-input layui-disabled" value="admin">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">旧密码：</label>
				    <div class="layui-input-block">
				      <input id="manager_password_raw" type="password" name="password1" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  <div class="layui-form-item">
				    <label class="layui-form-label">新密码：</label>
				    <div class="layui-input-block">
				      <input id="manager_password_new" type="password" name="password2" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				    </div>
				  </div>

				</form>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn layui-btn-normal" onclick="to_update_manager_password()">立即修改</button>
					</div>
				</div>
		    </div>
		  </div>
	</div>
	<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script>
		//Demo
		layui.use(['form','element'], function(){
		  var form = layui.form();
		  var element = layui.element();
		  form.render();

		});
		var layer;
		layui.use('layer',function(){
			layer=layui.layer;
		})
		function to_update_manager_password(){
			var manager_password_raw=$("#manager_password_raw").val();
			var manager_password_new=$("#manager_password_new").val();
			if(manager_password_raw==""){
				layer.msg("旧密码不能为空");
				return ;
			}
			if(manager_password_new==""){
				layer.msg("新密码不能为空");
				return ;
			}

			$.ajax({
				url:"${pageContext.request.contextPath}/other/main_manager_info_update_password.do",
				data:{
					"manager_password_raw":$("#manager_password_raw").val(),
					"manager_password_new":$("#manager_password_new").val()
				},
				success:function(data,status){
					if(status=="success"){
						if(data==1){
							layer.msg("修改失败，原密码错误");
							return ;
						}
						layer.msg("密码已修改");
					}
				}
			})
		}
		window.onload=function(){
			$.ajax({
				url:"${pageContext.request.contextPath}/other/main_manager_info_init.do",
				success:function (data,status){
					if(status=="success"){
						$("#manager_id").val(data.manager_id);
						$("#manager_name").val(data.manager_name);
						$("#manager_name_2").val(data.manager_name);
					}
				}
			});
		}
	</script>
	</body>
</html>
